package com.maud.history;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import android.app.Activity;
import android.graphics.Bitmap;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.genuine.hyjj.R;
import com.maud.util.BitMapUtil;

public class HistoryDetailListViewAdapter extends BaseAdapter {
	private List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
	private Activity context;

	public HistoryDetailListViewAdapter(List<Map<String, Object>> list,
			Activity context) {
		super();
		this.list = list;
		this.context = context;
	}

	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return list.size();
	}

	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return list.get(position);
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		LayoutInflater inflater = context.getLayoutInflater();
		View itemView = inflater.inflate(R.layout.history_detail_item, null);
		TextView txtName = (TextView) itemView
				.findViewById(R.id.history_detail_item_name);
		TextView txtPwd = (TextView) itemView
				.findViewById(R.id.history_detail_item_pwd);
		TextView txtCode = (TextView) itemView
				.findViewById(R.id.history_detail_item_code_no);
		TextView txtDate = (TextView) itemView
				.findViewById(R.id.history_detail_item_date);
		ImageView imageView = (ImageView) itemView
				.findViewById(R.id.history_detail_item_img);
		Map<String, Object> map = list.get(position);
		txtName.setText(map.get("name").toString());
		txtPwd.setText(map.get("pwd").toString());
		txtCode.setText(map.get("barCodeNo").toString());
		imageView.setImageBitmap((Bitmap)map.get("imageUrl"));
		txtDate.setText(map.get("createDate").toString());
		return itemView;
	}

}
